package com.handmark.pulltorefresh.library.internal;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Matrix;
import android.graphics.drawable.Drawable;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.RotateAnimation;
import android.widget.ImageView;

import com.handmark.pulltorefresh.library.PullToRefreshBase.Mode;
import com.handmark.pulltorefresh.library.PullToRefreshBase.Orientation;
import com.ss.android.article.browser.R;

@SuppressLint(value = {"ViewConstructor"})
public final class b extends com.handmark.pulltorefresh.library.internal.LoadingLayout {
    private final Animation m;
    private final Animation n;

    public b(Context arg9, Mode arg10, Orientation arg11, TypedArray arg12) {
        super(arg9, arg10, arg11, arg12);
        int v7 = arg10 == Mode.PULL_FROM_START ? -180 : 180;
        this.m = new RotateAnimation(0f, ((float) v7), 1, 0.5f, 1, 0.5f);
        this.m.setInterpolator(com.handmark.pulltorefresh.library.internal.b.a);
        this.m.setDuration(150);
        this.m.setFillAfter(true);
        this.n = new RotateAnimation(((float) v7), 0f, 1, 0.5f, 1, 0.5f);
        this.n.setInterpolator(com.handmark.pulltorefresh.library.internal.b.a);
        this.n.setDuration(150);
        this.n.setFillAfter(true);
    }

    public final void a() {
        if (this.m == this.c.getAnimation()) {
            this.c.startAnimation(this.n);
        }
    }

    public final void a(float arg1) {
    }

    public final void a(Drawable arg7) {
        float v5 = 2f;
        if (arg7 != null) {
            int v0 = arg7.getIntrinsicHeight();
            int v1 = arg7.getIntrinsicWidth();
            ViewGroup.LayoutParams v2 = this.c.getLayoutParams();
            int v3 = Math.max(v0, v1);
            v2.height = v3;
            v2.width = v3;
            this.c.requestLayout();
            this.c.setScaleType(ImageView.ScaleType.MATRIX);
            Matrix v3_1 = new Matrix();
            v3_1.postTranslate((((float) (v2.width - v1))) / v5, (((float) (v2.height - v0))) / v5);
            v3_1.postRotate(this.getDrawableRotationAngle(), (((float) v2.width)) / v5, (((float) v2.height)) / v5);
            this.c.setImageMatrix(v3_1);
        }
    }

    public final void b() {
        this.c.clearAnimation();
        this.c.setVisibility(INVISIBLE);
        this.d.setVisibility(VISIBLE);
    }

    public final void c() {
        this.c.startAnimation(this.m);
    }

    public final void d() {
        this.c.clearAnimation();
        this.d.setVisibility(GONE);
        this.c.setVisibility(VISIBLE);
    }

    public final int getDefaultDrawableResId() {
        return R.drawable.o0;
    }

    private float getDrawableRotationAngle() {
        switch (j) {
            case PULL_FROM_END:
                return this.k == Orientation.HORIZONTAL ? 90f : 180f;
            case PULL_FROM_START:
                return k == Orientation.HORIZONTAL ? 270f : 0f;
            default:
                return 0f;
        }
    }
}

